/**
 * 签到页面
 * author:yinht
 * date:2017年6月1日9:10:42
 */
;
define(function(require, exports, module) {
	var wechat = require("wechat");

	var birthdayremind = {
		/**
		 * bindEvent 页面事件
		 */
		bindEvent: function() {
			//返回
			$("#return_birthremind").unbind().on("click", function() {
				window.location.href = "#home";
			});
		}, 
		/**
		 * 进行页面路由监听配置
		 * 
		 */
		bindRout: function() {
			//公共页面监听路由
			Path.map("#home").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: true,
					from: "left"
				});
			});
			//公共页面监听路由
			Path.map("").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: true,
					from: "left"
				});
			});
			Path.map("#/index/:page_name").to(function() {
				console.log(this.params["page_name"]);
				var page_name = this.params["page_name"];
				var nextPageFrom = "right"; //从右边过来
				//记录状态
				common.loadPage({
					pageUrl: "html/" + page_name + ".html",
					reload: true,
					from: nextPageFrom
				});
			});
			Path.listen();
		},

		/**
		 * 页面数据加载
		 */
		loadData: function() {
			var pk_member = window.localStorage.getItem("pk_member");
			var pk_user = window.localStorage.getItem("pk_user");
			var listtype = "1";
			var param = {
				pk_user: pk_user,
				listtype: listtype,
				type: "2"    //正式会员的type
       			}
			common.loadData({
				url: "/service/RRTPubServlet?method=birthdayReminder", //"/UMPPubServlet?method=getWxUserInfo",
				param: param,
				successCallBack: birthdayremind.birthReminderCallBack, //回调函数
				dataSource: "birthReminder",
				cache: false
			});
			
		},
		birthReminderCallBack: function(json) {
			console.log(JSON.stringify(json));
			if(json.status == "0") {
				//展示页面
				var html = "";
				for(var i=0;i<json.data.list.length;i++){
					html+='<div class="genjin_item">'
						+'<div class="lf time_item">'
						+'<span>'+json.data.list[i].birthday+'</span>'
						+'<img src="images/dot.png" alt="" class="dot_img">'
						+'</div>'
						+'<div class="lf con_item">'
						+'<div class="st_item">'
						+'<h3 class="title_birth">生日提醒</h3>'
						+'<div class="get_content">'
						+json.data.list[i].message
						+'<a href="#/index/men_details" class="todetails" pk_member="'
						+json.data.list[i].pk_member
						+'"><span class="kehu_name">'+json.data.list[i].name+'</span></a>'
						+'</div></div></div></div>';
					$("#genjin_item").html(html);
					$(".todetails").unbind().on("click", function() {
						var pk_member = $(this).attr("pk_member");
						window.localStorage.setItem("pk_member",pk_member);
						window.localStorage.setItem("supertype","2");
						window.localStorage.setItem("ishide","true");
					})
				}	
			} else {
				common.showTip({
					content: json.message
				});
			}
			var iscroll = require("iscroll"); 
			common.initIscroll({
				container: "iscrollContent_birthremind",
				isVertical:true ,
				showScrollBar: true
			});
		},
		/**
		 * each page init mothed
		 */
		initialize: function() {

			this.loadData();
			//事件绑定
			this.bindEvent();
			//路由绑定
			this.bindRout();
		}
	};

	module.exports = birthdayremind;
});	

